export const Order = {
  state: {
    /***
     * state: 0待付款 1待发货 2待收货 3待评价
     */
    orders: [
      {
        shopId: 100001,
        state: 0,
        stateInfo: '等待买家付款',
        data: [
          { id: '1001', price: '18.80', num: 5, shop: '连城馆天水间白鹜鸭连城白鸭蛋', picture: 'https://image3.suning.cn/uimg/b2c/newcatentries/0070144986-000000000187331289_1_800x800.jpg' },
          { id: '1002', price: '78.10', num: 1, shop: '【苏宁生鲜】恒都巴西牛腩块1kg', picture: 'https://image1.suning.cn/uimg/b2c/newcatentries/0010128947-000000000614167327_1_800x800.jpg' }
        ]
      },
      {
        shopId: 100002,
        state: 1,
        stateInfo: '待发货',
        data: [
          { id: '1005', price: '118.80', num: 2, shop: '贝克巴斯(BECBAS)E50 厨房家用食物垃圾处理器', picture: 'https://image3.suning.cn/uimg/b2c/newcatentries/0000000000-000000000616963357_2_800x800.jpg' }
        ]
      },
      {
        shopId: 100003,
        state: 2,
        stateInfo: '待收货',
        data: [
          { id: '1004', price: '518.80', num: 1, shop: '沁园（QINYUAN）立式饮水机', picture: 'https://image5.suning.cn/uimg/b2c/newcatentries/0000000000-000000000834870991_1_800x800.jpg' }
        ]
      },
      {
        shopId: 100004,
        state: 3,
        stateInfo: '交易成功',
        data: [
          { id: '1003', price: '1308.80', num: 1, shop: '科龙(Kelon) 正1.5匹 定速 冷暖 空调挂机', picture: 'https://image4.suning.cn/uimg/b2c/newcatentries/0000000000-000000000178605073_1_800x800.jpg' }
        ]
      },
      {
        shopId: 100005,
        state: 3,
        stateInfo: '等待买家付款',
        data: [
          { id: '1001', price: '18.80', num: 5, shop: '连城馆天水间白鹜鸭连城白鸭蛋', picture: 'https://image3.suning.cn/uimg/b2c/newcatentries/0070144986-000000000187331289_1_800x800.jpg' },
          { id: '1005', price: '118.80', num: 2, shop: '贝克巴斯(BECBAS)E50 厨房家用食物垃圾处理器', picture: 'https://image3.suning.cn/uimg/b2c/newcatentries/0000000000-000000000616963357_2_800x800.jpg' }
        ]
      }
    ]
  },
  mutations: {
    /**
     * 取消订单
     * @param {*} state
     * @param {*} id
     */
    DELORDER (state, id) {
      const index = state.orders.findIndex(item => item.shopId === id)
      state.orders.splice(index, 1)
    }
  },
  actions: {
    delOrder ({ commit }, id) {
      commit('DELORDER', id)
    }
  }
}
